package model

import (
	"database/sql"
	"time"
)

type IrModelFields struct {
	ResCommon
	Name          string `json:"name"`
	Model         string `json:"model"`
	Relation      string `json:"relation"`
	RelationField string `json:"relation_field"`
	ModelId       int64  `json:"model_id"`
	TType         string `json:"ttype" gorm:"column:ttype"`
	RelationTable string `json:"relation_table"`
	Column1       string `json:"column1"`
	Column2       string `json:"column2"`
}
type IrModelFieldsSelection struct {
	ResCommon
	FieldId int64  `json:"field_id"`
	Value   string `json:"value"`
	Name    string `json:"name"`
}
type IrAttachment struct {
	ResCommon
	Name         string         `json:"name"`
	Description  string         `json:"description"`
	ResModel     string         `json:"resModel"`
	ResField     sql.NullString `json:"res_field"`
	ResId        int64          `json:"resId"`
	CompanyId    int64          `json:"companyId"`
	Type         string         `json:"type"`
	Url          string         `json:"url"`
	Public       bool           `json:"public"`
	AccessToken  string         `json:"accessToken"`
	DbDatas      []byte         `json:"dbDatas"`
	StoreFname   string         `json:"storeFname"`
	FileSize     int64          `json:"fileSize"`
	Checksum     string         `json:"checksum"`
	Mimetype     string         `json:"mimetype" gorm:"default:888"`
	IndexContent string         `json:"indexContent"`
	OriginalId   int            `json:"originalId"`
	FilePath     string         `json:"filePath"`
	Md5v         string         `json:"md5" gorm:"column:md5"`
	PreviewURL   string         `json:"previewURL" gorm:"-"`
	Active       bool           `json:"active"`
}
type IrLogin struct {
	Id          int64         `json:"id"`
	IP          string        `json:"ip"`
	Name        string        `json:"name"`
	ModelNumber string        `json:"model_number"`
	Login       string        `json:"login"`
	Date        time.Time     `json:"date"`
	State       string        `json:"state"`
	Error       string        `json:"error"`
	Browser     string        `json:"browser"`
	UserId      sql.NullInt64 `json:"user_id"`
}
type IrModelData struct {
	ResCommon
	Name   string
	ResId  int64
	Module string
	Model  string
}
type IrModuleCategory struct {
	ResCommon
	Name        string
	Description string
	ParentId    int64
	Sequence    int
	Visible     bool
	Exclusive   bool
}

type IrModel struct {
	ResCommon
	Name  string
	Model string
}

type IrMailServer struct {
	ResCommon
	Name               string
	FromFilter         string
	SmtpHost           string
	SmtpPort           int
	SmtpAuthentication string
	SmtpUser           string
	SmtpPass           string
	SmtpEncryption     string
	SmtpSslCertificate sql.NullString
	SmtpSslPrivateKey  sql.NullString
	Active             bool
	Sequence           int
}

type IrConfigParameter struct {
	ResCommon
	Key   string
	Value string
}

// IrUiMenu 菜单
type IrUiMenu struct {
	ResCommon
	Sequence   int
	ParentId   sql.NullInt64
	ParentPath string
	WebIcon    sql.NullString
	Action     sql.NullString
	Name       string
	Active     bool
}

type IrUiMenuGroupRel struct {
	MenuId int64
	Gid    int64
}

type IrActWindow struct {
	ResCommon
	BindingModelId   int64
	Type             string
	BindingType      string
	BindingViewTypes string
	Name             string
	Help             string
	ViewId           int64
	ResId            sql.NullInt64
	Limit            int
	SearchViewId     int64
	Domain           sql.NullString
	Context          string
	ResModel         string
	Target           sql.NullString
	ViewMode         string
	Usage            string
	Filter           sql.NullBool
}

type IrActClient struct {
	ResCommon
	BindingModelId   int64
	Type             string
	BindingType      string
	BindingViewTypes string
	Name             string
	Help             string
	Tag              string
	Target           sql.NullString
	ResModel         sql.NullString
	Context          string
}
type IrActUrl struct {
	ResCommon
	BindingModelId  int64
	Type            string
	BindingType     string
	BindingViewType string
	Name            string
	Help            string
	Target          sql.NullString
	Url             string
}

type IrUiView struct {
	ResCommon
	Name string
	Type string
}

type IrActWindowView struct {
	ResCommon
	Sequence    int
	ViewId      int64
	View        IrUiView
	ActWindowId int64
	ViewMode    string
	Multi       string
}
